VirtualVolume Class

Enables you to create and maintain a hierarchy of "virtual" files within one physical file. Basic reading and writing text and binary streams are supported.

Events

None

Properties

Root


Methods

None

More information available in parent classes: Object


Notes

The FolderItem class has two methods and one property for working with virtual volumes. Use the CreateAsVirtualVolume and OpenAsVirtualVolume methods to create and open virtual volumes. The VirtualVolume property of the FolderItem class returns the VirtualVolume if the FolderItem is in a virtual volume.

Once you've created a VirtualVolume, you can get its Root and navigate to it using the same FolderItem methods that you would for real files. Virtual files are cross-platform compatible, and support basic reading and writing as text or binary files. The SaveAsPicture and SaveStyledEditField methods of the FolderItem class do not work for virtual volumes. Virtual volumes do not support resource forks.

Virtual volumes flush their data to disk whenever a virtual volume is closed. This helps ensure that your data is safely on disk in the event of a crash or loss of power.

Filenames can be up to 223 bytes long. Paths are not supported, but directories are (e.g., create a virtual directory with the CreateAsFolder method of the FolderItem class, and navigate to it with the Child or Item methods of this class). The virtual file system supports four-byte type codes (accessed via f.MacType), but does not support creator codes.


Example

The following example creates a VirtualVolume, gets its Root property, and writes a text file to the virtual volume.

Dim vv As VirtualVolume
Dim realFile As FolderItem
Dim virtFile As FolderItem
Dim outp As TextOutputStream

realFile = GetFolderItem("").Child("VV"))
vv = realFile.CreateVirtualVolume
If vv = Nil then
MsgBox "Unable to create virtual volume"
else
  virtFile = vv.Root.Child("Virtual File.txt")
  outp = virtFile.CreateTextFile
  outp.Write "Hello world!"
end if

To access an existing virtual volume, use the OpenAsVirtualVolume method instead of the CreateVirtualVolume method of the FolderItem class.


See Also

FolderItem class.